difference_update() Function of sets in python

39

# The difference_update() function can be used to update a set by removing values
# that are shared with another given set

mySet = {1, 2, 3, 4}
mySet2 = {3, 4, 5, 6}
mySet.difference_update(mySet2)
print(mySet)

# Output:
# {1, 2}

Comments

Submit
0 Comments